<?php
	// Lấy mã sách từ thanh địa chỉ
	$id = $_GET['msp'];
	$sanpham = new sanphambs();
	$sanpham->MaSanPham = $id;
	$danhsach = $sanpham->GetList();
	
?>
<h3>Sửa thông tin sản phẩm</h3>
<form action="index.php?do=sanpham_sua_xuly" method="post" >
	<input type="hidden" value="<?php echo $id ?>" name="MaSanPham" />
	<table class="Form">
		<tr>
			<td width="20%">Tên sản phẩm:</td>
			<td><input type="text" value="<?php echo $danhsach[0]['TenSanPham']; ?>" name="TenSanPham" /><span class="requirefield">*</span></td>
		</tr>
		<tr>
			<td>Loại sách:</td>
			<td>
				<select name="MaLoai">
				<?php
				 
					$loaisp = new loaispbs();
					$dmls = $loaisp->GetList();
					
					for($i = 0; $i < count($dmls); $i++)
					{
						if($dmls[$i]['MaLoai'] == $danhsach[0]['MaLoai'])
							echo "<option value='{$dmls[$i]['MaLoai']}' selected='selected'>{$dmls[$i]['TenLoai']}</option>";
						else
							echo "<option value='{$dmls[$i]['MaLoai']}'>{$dmls[$i]['TenLoai']}</option>";
					}
				?>
				</select><span class="requirefield">*</span>
			</td>
		</tr>
		<tr>
			<td>Nhà sản xuất:</td>
			<td>
				<select name="MaNhaSX">
				<?php
					$nhasx = new nhasanxuatbs();
					
					$dmnxb = $nhasx->GetList();
					
					for($i = 0; $i < count($dmnxb); $i++)
					{
						if($dmnxb[$i]['MaNhaSX'] == $danhsach[0]['MaNhaSX'])
							echo "<option value='{$dmnxb[$i]['MaNhaSX']}' selected='selected'>{$dmnxb[$i]['TenNhaSX']}</option>";
						else
							echo "<option value='{$dmnxb[$i]['MaNhaSX']}'>{$dmnxb[$i]['TenNhaSX']}</option>";
					}
				?>
				</select><span class="requirefield">*</span>
			</td>
		</tr>
        
        <tr>
			<td>Chất liệu:</td>
			<td>
				<select name="MaChatLieu">
				<?php
					$chatlieu = new chatlieubs();
					
					$dmcl = $chatlieu->GetList();
					
					for($i = 0; $i < count($dmcl); $i++)
					{
						if($dmcl[$i]['MaChatLieu'] == $danhsach[0]['MaChatLieu'])
							echo "<option value='{$dmcl[$i]['MaChatLieu']}' selected='selected'>{$dmcl[$i]['TenChatLieu']}</option>";
						else
							echo "<option value='{$dmcl[$i]['MaChatLieu']}'>{$dmcl[$i]['TenChatLieu']}</option>";
					}
				?>
				</select><span class="requirefield">*</span>
			</td>
		</tr>
        
        <td>Nhóm hàng:</td>
			<td>
				<select name="MaNhomHang">
				<?php
					$nhomhang = new nhomhangbs();
					
					$dmnh = $nhomhang->GetList();
					
					for($i = 0; $i < count($dmnh); $i++)
					{
						if($dmnh[$i]['MaNhomHang'] == $danhsach[0]['MaNhomHang'])
							echo "<option value='{$dmnh[$i]['MaNhomHang']}' selected='selected'>{$dmnh[$i]['TenNhomHang']}</option>";
						else
							echo "<option value='{$dmnh[$i]['MaNhomHang']}'>{$dmnh[$i]['TenNhomHang']}</option>";
					}
				?>
				</select><span class="requirefield">*</span>
			</td>
		</tr>
		<tr>
			<td>Đơn giá:</td>
			<td><input type="text" value="<?php echo $danhsach[0]['DonGia']; ?>" name="DonGia" /> (VNĐ)<span class="requirefield">*</span></td>
		</tr>
		<tr>
			<td>Số lượng:</td>
			<td><input type="text" value="<?php echo $danhsach[0]['SoLuong']; ?>" name="SoLuong" /><span class="requirefield">*</span></td>
		</tr>
        <tr>
            <td>Kích thươc:</td>
            <td>
                    <select name="MaKichThuoc">
                    <?php
                            $kichthuoc = new kichthuocbs();
                            $dmkt = $kichthuoc->GetList();
                            for($i = 0; $i < count($dmkt); $i++)
                            {
								if($dmkt[$i]['MaKichThuoc'] == $danhsach[0]['MaKichThuoc'])
									echo "<option value='{$dmkt[$i]['MaKichThuoc']}' selected='selected'>{$dmkt[$i]['KichThuoc']}</option>";
								else
									echo "<option value='{$dmkt[$i]['MaKichThuoc']}'>{$dmkt[$i]['KichThuoc']}</option>";
									   
                            }
                    ?>
                    </select><span class="requirefield">*</span>
            </td>
        </tr>
        <tr>
                <td>Kiểu dáng:</td>
                <td>
                        <select name="MaKieuDang">
                        <?php
                                $kieudang = new kieudangbs();
                                $dmkd = $kieudang->GetList();
                                for($i = 0; $i < count($dmkd); $i++)
                                {
									if($dmkd[$i]['MaKieuDang'] == $danhsach[0]['MaKieuDang'])
										echo "<option value='{$dmkd[$i]['MaKieuDang']}' selected='selected'>{$dmkd[$i]['KieuDang']}</option>";
									else
										echo "<option value='{$dmkd[$i]['MaKieuDang']}'>{$dmkd[$i]['KieuDang']}</option>";
									   
                                }
                        ?>
                        </select><span class="requirefield">*</span>
                </td>
        </tr>
        <tr>
                <td>Màu sắc:</td>
                <td><input type="text" value="<?php echo $danhsach[0]['MauSac']; ?>" name="MauSac" /><span class="requirefield">*</span></td>
        </tr>
		<tr>
			<td>Mô tả:</td>
			<td><textarea name="MoTa" rows="5" cols="50"><?php echo $danhsach[0]['MoTa']; ?></textarea>
            	<script type="text/javascript">
					var editor = CKEDITOR.replace('MoTa');
				</script>
            </td>
		</tr>
	</table>
	<p class="requirefields">(*): Trường bắt buộc phải nhập thông tin.</p>
	<input type="submit" value="Cập nhật vào CSDL" />
</form>